package com.heqiang.controller;

import com.heqiang.domain.Admin;
import com.heqiang.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author zhangheqiang
 * @Date 2020/3/18
 **/
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    AdminService service;


    /***************************************************** Query ******************************************************/
    @RequestMapping("/findAll")
    public Page<Admin> findAll(Admin admin) {
        Page<Admin> list = service.findAll(admin);
        return list;
    }

    @RequestMapping("/findById/{id}")
    public Admin findById(@PathVariable(value = "id") Long id) {
        return service.findById(id);
    }
    /***************************************************** Modify *****************************************************/
    @RequestMapping("/add")
    public boolean add(Admin admin) {
        return service.add(admin);
    }

    @RequestMapping("/del/{id}")
    public boolean del(@PathVariable Long id) {
        return service.del(id);
    }

    @RequestMapping("/modify")
    public boolean edit(@PathVariable Admin admin) {
        return service.modify(admin);
    }

}
